﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace TCPIPControl.StructHelper
{
    /// <summary>
    /// 网络通信总配置包
    /// </summary>
    [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4)]
    //[Serializable]
    public struct ACQParametersConfig
    {
        ///// <summary>
        ///// 下位机IP
        ///// </summary>
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
        //public byte[] IPAddress;

        ///// <summary>
        ///// 下位机端口号
        ///// </summary>
        //public long ClientPortNum;

        ///// <summary>
        ///// 采样方式   no use
        ///// </summary>
        //public UInt32 AcquisitionType;

        ///// <summary>
        ///// 界面刷新  值：(1/2/3/4/5)秒  
        ///// </summary>
        //public UInt32 UIRefreshFrequency;
        ///// <summary>
        ///// 系统调试 //0:不选中；1：选中调试模式；
        ///// </summary>
        //public UInt32 SystemDebug;
        ///// <summary>
        ///// 本地存储       0：开始存储，1：关闭
        ///// </summary>
        //public UInt32 LocalSave;
        //// xxxxx
        ///// <summary>
        ///// 小时库     值：2/4/6/8/10/15秒
        ///// </summary>
        //public UInt32 HourDBInterval;
        //// xxxxx 
        ///// <summary>
        ///// 天库        值：1/2/3/4/5分钟
        ///// </summary>
        //public UInt32 DayDBInterval;
        //// xxxxx
        ///// <summary>
        ///// 周库       值：7/14/21/28/35分钟
        ///// </summary>
        //public UInt32 WeekDBInterval;
        //// xxxxx
        ///// <summary>
        ///// 月库      值：30/60/90/120/150分钟 xxxxx
        ///// </summary>
        //public UInt32 MonthDBInterval;
        ///// <summary>
        ///// 年库      值：6/12/18/24/30小时
        ///// </summary>
        //public UInt32 YearDBInterval;

        ///// <summary>
        ///// 变负荷库
        ///// </summary>
        //public UInt32 VariableLoadDB;

        ///// <summary>
        ///// 升数据库
        ///// </summary>
        //public UInt32 StartSpeed;

        ///// <summary>
        ///// 降数据库
        ///// </summary>
        //public UInt32 StopSpeed;
        ////      xxxxx
        ///// <summary>
        ///// 黑匣子事件前
        ///// </summary>
        //public UInt32 BlackboxBeforeEvent;

        ///// <summary>
        ///// 黑匣子事件后
        ///// </summary>
        //public UInt32 BlackboxAfterEvent;
        ///// <summary>
        ///// 黑匣子转速上限
        ///// </summary>
        //public UInt32 BlackBoxSUpLimit;
        ///// <summary>
        ///// 黑匣子转速下限
        ///// </summary>
        //public UInt32 BlackBoxSDownLimit;

        ///// <summary>
        ///// 黑匣子保存频率
        ///// </summary>
        //public UInt32 BlackBoxSavFre;

        ///// <summary>
        ///// 驱动软件版本
        ///// </summary>
        //public byte VerDriver;

        ///// <summary>
        ///// 系统软件版本
        ///// </summary>
        //public byte VerSysSoftware;

        ///// <summary>
        ///// FPGA软件主版本
        ///// </summary>
        //public UInt16 VerFPGAMain;

        ///// <summary>
        ///// FPGA采集卡版本
        ///// </summary>
        //public UInt16 VerFPGACollect;

        ///// <summary>
        ///// 测点配置，最多32个测点
        ///// </summary>
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        //public TestPoint[] TestPoint_Data;

        ///// <summary>
        ///// 三相加速度测点
        ///// </summary>
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
        //public TriAccTestPointCon[] TriAccTestPointConfig_Data;

        ///// <summary>
        ///// 转速配置，最多6个转速值
        ///// </summary>
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        //public SpeedConfig[] SpeedConfigt_Data;

        ////转速配置，最多6个转速值
        ///// <summary>
        ///// 通道配置
        ///// </summary>
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        //public ChannelConfig[] ChannelConfig_Data;


        public byte ChannelNo;//通道ID
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
        public byte[] ChannelID;//通道名称
        public byte Enable;//通道使能
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] Name;//测点名称
        public byte Direction;//安装方向
        public byte SigType;//信号类型
        public byte SigUnit;//信号单位
        public float Sensitivity;//传感器灵敏度
        public byte SensitivityUnit;//灵敏度单位
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] SensorType;//传感器型号
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] SensorManufacture;//传感器制作商
        public UInt64 SensorNo;//传感器序列号
    }


    /// <summary>
    /// 测点配置
    /// </summary>
    /// 
    [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4)]
    public struct TestPoint
    {
        /// <summary>
        /// 通道使能
        /// </summary>
        public char enable;

        /// <summary>
        /// 测点名称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] TestPointName;

        /// <summary>
        /// 测点X轴通道ID  值从1开始   xxxxx
        /// </summary>
        public UInt16 TestPointXChannelID;

        /// <summary>
        /// 测点Y轴通道ID  值从1开始   xxxxx
        /// </summary>
        public UInt16 TestPointYChannelID;

        /// <summary>
        /// 轴承座X方向双侧间隙
        /// </summary>                                              
        public float bearhousx;

        /// <summary>
        /// 轴承座y方向双侧间隙
        /// </summary>
        public float bearhousy;

        /// <summary>
        /// X轴初始位置修正
        /// </summary>
        public float iniaxlex;

        /// <summary>
        /// Y轴初始位置修正
        /// </summary>
        public float iniaxley;

        /// <summary>
        /// 轴承座横向偏移
        /// </summary>
        public float bearhori;

        /// <summary>
        /// 轴承座纵向标高
        /// </summary>
        public float bearveri;
    }

    /// <summary>
    /// 三向加速度测点配置
    /// </summary>
    /// 
    [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4)]
    public struct TriAccTestPointCon
    {
        /// <summary>
        /// 测点使能
        /// </summary>
        public char enable;
        /// <summary>
        /// 测点名称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] TestpointName;
        /// <summary>
        /// 测点X轴ID
        /// </summary>                  
        public UInt16 TestPointXChannelID;
        /// <summary>
        /// 测点Y轴ID
        /// </summary>
        public UInt16 TestPointYChannelID;

        /// <summary>
        /// 测点Z轴ID
        /// </summary>
        public UInt16 TestPointZChannelID;
    }


    /// <summary>
    /// 转速配置
    /// </summary>
    /// 
    [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4)]
    public struct SpeedConfig
    {
        /// <summary>
        /// 转速通道使能
        /// </summary>
        public char enable;

        /// <summary>
        /// 键相ID 值从1开始
        /// </summary>
        public UInt16 KeyPhaseID;

        /// <summary>
        /// 键相名称 xxxxx
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] KeyPhaseName;

        /// <summary>
        /// 键相安装角度   xxxxx
        /// </summary>
        public float KeyPhaseAngle;

        /// <summary>
        /// 旋转方向 0：顺时针  1：逆时针    xxxxx
        /// </summary>
        public UInt16 RotationDirection;

        /// <summary>
        /// 运行模式    1：键相槽手动，2：键相槽手动，3:齿轮盘手动，4：齿轮盘自动，0：无效数据
        /// </summary>	
        public byte RunMod;

        /// <summary>
        /// 比较电压系树齿轮齿数
        /// </summary>
        public byte CompareVol;

        /// <summary>
        /// 齿轮齿数
        /// </summary>  
        public UInt16 GearTeethNum;

        public float KeySlotMax;

        public float KeySlotMin;

        public float GearMax;

        public float GearMin;

        public float GearKey;
    }

    /// <summary>
    /// 通道配置
    /// </summary>
    /// 
    [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4)]
    public struct ChannelConfig1
    {
        /// <summary>
        /// 通道使能
        /// </summary>
        public char enable;

        /// <summary>
        /// 通道ID 值从1开始                
        /// </summary>
        public UInt16 ChannelId;
        /// <summary>
        /// 转速编号
        /// </summary>
        public UInt16 SpeedNum;

        /// <summary>
        /// 通道名称        
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] ChannelName;

        /// <summary>
        /// 安装角度        
        /// </summary>
        public float InstallationAngle;

        /// <summary>
        /// 传感器类型 0：位移，1：速度，2：加速度 xxxxx
        /// </summary>                                                           										
        public UInt16 SensorType;

        /// <summary>
        /// 灵敏度系数 
        /// </summary>
        public float Sensitivity;

        /// <summary>
        /// 偏移量 
        /// </summary>
        public float OffsetValue;

        /// <summary>
        /// 矫正系数       
        /// </summary>
        public float Linearity;

        /// <summary>
        /// 零点偏移       
        /// </summary>                                     
        public float ZeroOffset;
        /// <summary>
        /// 可选频段1
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] Band1;

        /// <summary>
        /// 可选频段1上限
        /// </summary>
        public float ULimit1;

        /// <summary>
        /// 可选频段1下限
        /// </summary>
        public float LLimit1;

        /// <summary>
        /// 可选频段2
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] Band2;

        /// <summary>
        /// 可选频段2上限
        /// </summary>
        public float ULimit2;
        //      xxxxx
        /// <summary>
        /// 可选频段2下限
        /// </summary>
        public float LLimit2;

        /// <summary>
        /// 可选频段3
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public char[] Band3;

        //     xxxxx
        /// <summary>
        /// 可选频段3上限
        /// </summary>
        public float ULimit3;

        /// <summary>
        /// 可选频段3下限
        /// </summary>
        public float LLimit3;

        /// <summary>
        /// 可选频段1黄色报警值
        /// </summary>
        public float Band1YellowValue;

        /// <summary>
        /// 可选频段1红色报警值
        /// </summary>
        public float Band1RedValue;

        /// <summary>
        /// 可选频段1报警值是否启用 0：不启用，1：启用    xxxxx
        /// </summary>
        public UInt16 Band1IsUser;

        /// <summary>
        /// 可选频段2黄色报警值
        /// </summary>
        public float Band2YellowValue;

        /// <summary>
        /// 可选频段2红色报警值
        /// </summary>
        public float Band2RedValue;

        /// <summary>
        /// 可选频段2报警值是否启用 0：不启用，1：启用   xxxxx
        /// </summary>
        public UInt16 Band2IsUser;
        /// <summary>
        /// 可选频段3黄色报警值
        /// </summary>
        public float Band3YellowValue;

        /// <summary>
        /// 可选频段3红色报警值
        /// </summary>
        public float Band3RedValue;

        /// <summary>
        /// 可选频段3报警值是否启用 0：不启用，1：启用
        /// </summary>
        public UInt16 Band3IsUser;

        /// <summary>
        /// 半频幅值黄色报警值
        /// </summary>
        public float HalfAmplitudeYellowValue;

        /// <summary>
        /// 半频幅值红色报警值
        /// </summary>
        public float HalfAmplitudeRedValue;

        /// <summary>
        /// 半频幅值报警值是否启用 0：不启用，1：启用   xxxxx
        /// </summary>
        public UInt16 HalfAmplitudeIsUser;
        /// <summary>
        /// 一倍频幅值黄色报警值
        /// </summary>
        public float OneAmplitudeYellowValue;
        //     xxxxx
        /// <summary>
        /// 一倍频幅值红色报警值
        /// </summary>
        public float OneAmplitudeRedValue;
        //        xxxxx
        /// <summary>
        /// 一倍频幅值报警值是否启用 0：不启用，1：启用   xxxxx
        /// </summary>
        public UInt16 OneAmplitudeIsUser;
        /// <summary>
        /// 通频值黄色报警值
        /// </summary>
        public float PassAmplitudeYellowValue;
        /// <summary>
        /// 通频值红色报警值
        /// </summary>
        public float PassAmplitudeRedValue;
        /// <summary>
        /// 通频值报警值是否启用 0：不启用，1：启用
        /// </summary>
        public UInt16 PassAmplitudeIsUser;
        //   xxxxx
        /// <summary>
        /// 二倍频幅值黄色报警值
        /// </summary>
        public float TwoAmplitudeYellowValue;
        /// <summary>
        /// 二倍频幅值红色报警值
        /// </summary>
        public float TwoAmplitudeRedValue;
        /// <summary>
        ///二倍频幅值报警值是否启用	0：不启用，1：启用
        /// </summary>     
        public UInt16 TwoAmplitudeIsUser;

        /// <summary>
        /// 加速度高频端
        /// </summary>
        public float AccHighAmplitudeYellowValue;

        public float AccHighAmplitudeRedValue;

        public UInt16 AccHighAmplitudeIsUser;

        /// <summary>
        /// 加速度低频段
        /// </summary>
        public float AccLowAmplitudeYellowValue;

        public float AccLowAmplitudeRedValue;

        public UInt16 AccLowAmplitudeIsUser;

        /// <summary>
        /// 加速度全频段
        /// </summary>
        public float AccTotalAmplitudeYellowValue;

        public float AccTotalAmplitudeRedValue;

        public UInt16 AccTotalAmplitudeIsUser;
    }
}
